package com.losdun.points.domain;

import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.losdun.common.utils.DateUtils;
import com.losdun.points.enums.PointsOrderStatusEnum;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;


/**
 * 积分订单表 数据库实体
 *
 * @author swordye
 * @date 2025-05-19
 */
@Data
@TableName("points_order")
public class PointsOrder implements Serializable {

    /**  */
    private Long id;

    /** 订单编号 */
    private String orderNo;

    /** 商品ID */
    private String goodsId;

    private Integer goodsPoints;

    private Integer goodsNum;

    /** 用户ID */
    private Long userId;

    /** 总消耗积分 */
    private Integer totalPoints;

    /** 状态:0-待处理 1-已发货 2-已完成 3-已取消 */
    private Integer status;

    /** 收货人姓名 */
    private String receiverName;

    /** 收货人电话 */
    private String receiverPhone;

    /** 收货地址 */
    private String receiverAddress;

    /** 快递名称 */
    private String deliveryName;

    /** 快递单号 */
    private String deliveryCode;
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime deliveryTime;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime receivedTime;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime cancelTime;
    /** 备注 */
    private String remark;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;


    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    @TableField(exist = false)
    private PointsGoods goods;

    public String getCancelTime(){
        return cancelTime!=null ? DateUtils.formatDateTime(cancelTime):null;
    }
    public String getDeliveryTime() {
        return deliveryTime!=null ? DateUtils.formatDateTime(deliveryTime):null;
    }

    public String getReceivedTime() {
        return receivedTime!=null ?DateUtils.formatDateTime(receivedTime):null;
    }

    public String getCreateTime() {
        return createTime!=null ? DateUtils.formatDateTime(createTime):null;
    }

    public String getUpdateTime() {
        return updateTime!=null ? DateUtils.formatDateTime(updateTime):null;
    }
    public String getStatusText(){
       return PointsOrderStatusEnum.getStatusText(status);
    }
}
